﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Scheduler {

    class DiscoveryBuffer {
        
        List<Object> executablesHighPriority = new List<Object>();
        List<Object> executablesLowPriority = new List<Object>();
        static int count = 0;

        public void addNewPacket(object dataPacket, Priority priority) {

            if (priority == Priority.HIGH_PRIORITY) {
                executablesHighPriority.Add(dataPacket);

            } else if (priority == Priority.LOW_PRIORITY) {

                executablesLowPriority.Add(dataPacket);
            }
        }

        /// <summary>
        /// For Priority Based Scheduling
        /// </summary>
        /// <returns></returns>
        public object getNextData() {
            object returnData = null;
            count++;
            if (count <= 3 && executablesHighPriority.Count > 0) {

                returnData = executablesHighPriority[0];
                executablesHighPriority.Remove(0);
                Console.WriteLine("Getting High");
                return returnData;

            } else if (count > 3 && executablesLowPriority.Count > 0) {
                
                returnData = executablesLowPriority[0];
                executablesLowPriority.Remove(0);
                Console.WriteLine("Getting Low");
                return returnData;

            } else if (count > 6) {
                count = 0;
            }
            return returnData;
        }

        public String toString() {
            return "Disc";
        }
    }

   
}
